#include<iostream>

using namespace std;

//
void input(int a[], int n) {
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
}

void output(int a[], int n) {
    for (int i = 0; i < n; i++) {
        cout << a[i] << " ";
    }
    cout << endl;
}

//选择排序算法
void sort(int a[], int n) {
    for (int i = 0; i < n; ++i) {
        //a[0..i-1] is sorted, a[i..n-1] is unsorted
        //find the minimum element index k  of unsorted array
        //then swap a[k] and a[i]
        int k = i;
        for (int j = i + 1; j < n; j++) {
            if (a[j] < a[k]) {
                k = j;
            }
        }
        if (i != k) {
            swap(a[i], a[k]);
        }
        output(a, n);
    }
}

int main() {
    int a[10] = {1, 3, 5, 7, 9, 2, 4, 6, 8, 0};
    sort(a, 10);
    output(a, 10);


    return 0;
}
